package com.jtny.nytb.equipment.utils;

import com.jtny.component.dto.CurrentUserDTO;
import org.springframework.stereotype.Component;

/**
 * @author 智慧能源中心 - 伍天宇
 * @package com.jtny.nytb.energymonitor.utils
 * @fileName ThreadLocalUtils.java
 * @createTime 2023年11月28日 16:33
 * @Copyright© 2023 jtny
 * 江投能源技术研究院 版权所有
 */
@Component
public class ThreadLocalUtils {

    public static ThreadLocal<String> localTenantCode = new ThreadLocal<>();

    public static ThreadLocal<CurrentUserDTO> currentUserDTO = new ThreadLocal<>();

    public static String getTenantCode() {
        return localTenantCode.get();
    }

    public static void removeTenantCode() {
        localTenantCode.remove();
    }


    public static void setTenantCode(String tenantCode) {
        localTenantCode.set(tenantCode);
    }

    public static CurrentUserDTO getCurrentUser() {
        return currentUserDTO.get();
    }

    public static void setCurrentUser(CurrentUserDTO currentUser) {
        currentUserDTO.set(currentUser);
    }

}
